package com.shouxin.attendance.database.model;

import com.shouxin.attendance.database.dao.BabyDao;
import com.shouxin.attendance.database.dao.DaoSession;
import com.shouxin.attendance.database.dao.PushDataDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;

@Entity(nameInDb = "t_push_data")
public class PushData {
    @Id
    private Long id;
    private Long babyId;
    @NotNull
    private Long sendTime;
    private Integer status;

    private int exceptionCode;
    @ToOne(joinProperty = "babyId")
    private Baby baby;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 166923942)
    private transient PushDataDao myDao;

    @Generated(hash = 360268269)
    private transient Long baby__resolvedKey;

    @Generated(hash = 283600095)
    public PushData(Long id, Long babyId, @NotNull Long sendTime, Integer status,
                    int exceptionCode) {
        this.id = id;
        this.babyId = babyId;
        this.sendTime = sendTime;
        this.status = status;
        this.exceptionCode = exceptionCode;
    }
    @Generated(hash = 350005849)
    public PushData() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getBabyId() {
        return this.babyId;
    }

    public void setBabyId(Long babyId) {
        this.babyId = babyId;
    }

    public Long getSendTime() {
        return this.sendTime;
    }

    public void setSendTime(Long sendTime) {
        this.sendTime = sendTime;
    }

    public Integer getStatus() {
        return this.status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public int getExceptionCode() {
        return exceptionCode;
    }

    public void setExceptionCode(int exceptionCode) {
        this.exceptionCode = exceptionCode;
    }

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1198133836)
    public Baby getBaby() {
        Long __key = this.babyId;
        if (baby__resolvedKey == null || !baby__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            BabyDao targetDao = daoSession.getBabyDao();
            Baby babyNew = targetDao.load(__key);
            synchronized (this) {
                baby = babyNew;
                baby__resolvedKey = __key;
            }
        }
        return baby;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 184915404)
    public void setBaby(Baby baby) {
        synchronized (this) {
            this.baby = baby;
            babyId = baby == null ? null : baby.getId();
            baby__resolvedKey = babyId;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 864840930)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getPushDataDao() : null;
    }
}
